package main

import (
	"fmt"
)

func main() {
	//第一种声明
	var test1 map[string]string
	//在使用map前，需要先make，make的作用就是给map分配数据空间
	test1 = make(map[string]string, 10)
	test1["one"] = "php"
	test1["two"] = "go"
	test1["three"] = "java"
	fmt.Println(test1)

	//第二种声明
	test2 := make(map[string]string)
	test2["one"] = "php"
	test2["two"] = "go"
	test2["three"] = "java"
	fmt.Println(test2)

	//第三种声明
	test3 := map[string]string{
		"one":   "php",
		"two":   "golang",
		"three": "java",
	}
	fmt.Println(test3)

	language := make(map[string]map[string]string)
	language["php"] = make(map[string]string, 2)
	language["php"]["id"] = "1"
	language["php"]["des"] = "php是世界上最好的语言"

	language["golang"] = make(map[string]string, 2)
	language["golang"]["id"] = "2"
	language["golang"]["des"] = "golang抗并发非常good"

	fmt.Println(language)

	val, key := language["php"]
	if key {
		fmt.Printf("%v", val)
	} else {
		fmt.Printf("no")
	}
	fmt.Println("=======")
	language["php"]["id"] = "3"
	language["php"]["nickname"] = "拍黄片"
	delete(language, "php")
	fmt.Println(language)

}
